import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author xiakf
 * @date: 2021/10/29 16:25
 * @description: 身份证验证正确性
 */
public class IDcard {

    private static final Integer[] COEFFICIENT ={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};

    public static void main(String[] args) {
        System.out.println(check("身份证号码"));
    }


     public static Boolean check (String number){
         String substring = number.substring(0, 17);
         char[] charArray = substring.toCharArray();
         int num=0;
         for(int i = 0; i < 17; i++) {
             num += COEFFICIENT[i] * Integer.parseInt(String.valueOf(charArray[i]));
         }
         int reNum = num % 11;
         int lastNum = 12 - reNum;
         int lastReNum=lastNum % 11;
         return number.endsWith(lastReNum == 10 ? "x" : String.valueOf(lastReNum));
     }



}
